package com.xuerhua.yxt.wechat.utils;

import java.util.Date;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.alibaba.fastjson.JSONObject;
import com.xuerhua.yxt.common.WechatConfigure;
import com.xuerhua.yxt.common.enums.WeekCommentStatus;
import com.xuerhua.yxt.model.SchoolInfo;
import com.xuerhua.yxt.utils.DateUtil;
import com.xuerhua.yxt.utils.HttpClientUtils;
import com.xuerhua.yxt.utils.TextUtil;
import com.xuerhua.yxt.wechat.template.Data_ChildName;
import com.xuerhua.yxt.wechat.template.Data_First;
import com.xuerhua.yxt.wechat.template.Data_Keyword;
import com.xuerhua.yxt.wechat.template.Data_Remark;
import com.xuerhua.yxt.wechat.template.Data_Score;
import com.xuerhua.yxt.wechat.template.Data_Time;
import com.xuerhua.yxt.wechat.template.OutputTemateData;
import com.xuerhua.yxt.wechat.template.TemplateDate;

public class TemplateUtil {
	static Logger logger = LoggerFactory.getLogger(TemplateUtil.class);
	
	
	/**
	 * 学校通知
	 * @param openid
	 * @param sendee 接收人
	 * @param schoolName 学校
	 * @param sender 发送人
	 * @param content 消息内容
	 * @param templateId 模板编号
	 */
	public static void schoolNoticeSend(SchoolInfo school,String openid, String sendee, String schoolName, 
			String sender, String content, String templateId, String reqUrl) {
		String url = TextUtil.format(WechatConfigure.getInstance().getTemplateMsg(), 
				school.getAccessToken());
		OutputTemateData outputData = new OutputTemateData();
		outputData.setTouser(openid);
		outputData.setTemplate_id(templateId);
		TemplateDate templateDate = new TemplateDate();
		Data_First first = new Data_First();
		first.setValue("您好，亲爱的" + sendee);
		first.setColor("#18b4ed");
		Data_Keyword keyword1 = new Data_Keyword();
		keyword1.setValue(schoolName);
		Data_Keyword keyword2 = new Data_Keyword();
		keyword2.setValue(sender + "老师");
		Data_Keyword keyword3 = new Data_Keyword();
		keyword3.setValue(DateUtil.dateToStr(new Date(), DateUtil.DEFAULT_DATE_FORMAT));
		Data_Keyword keyword4 = new Data_Keyword();
		keyword4.setValue(content);
		keyword4.setColor("#19c43e");
		Data_Remark remark = new Data_Remark();
		remark.setValue("\n\n❀❀❀欢迎使用"+school.getSchoolName()+"公众号❀❀❀");
		outputData.setUrl(reqUrl);
		templateDate.setFirst(first);
		templateDate.setKeyword1(keyword1);
		templateDate.setKeyword2(keyword2);
		templateDate.setKeyword3(keyword3);
		templateDate.setKeyword4(keyword4);
		templateDate.setRemark(remark);
		outputData.setData(templateDate);
		try {
			String json = JSONObject.toJSONString(outputData);
			json = json.replace("clazz", "class");
			logger.info("----schoolNoticeSend, param={}", json);
			HttpClientUtils.postStringJosn(url, json);
		} catch (Exception e) {
			logger.error("--schoolNoticeSend, error={}", e);
		}
	}
	
	/**
	 * 学校通知
	 * @param openid
	 * @param sendee 接收人
	 * @param schoolName 学校
	 * @param sender 发送人
	 * @param content 消息内容
	 * @param templateId 模板编号
	 */
	public static void classNoticeSend(SchoolInfo school,String openid, String sendee, String schoolName, 
			String sender, String content, String templateId, String reqUrl) {
		String url = TextUtil.format(WechatConfigure.getInstance().getTemplateMsg(), 
				school.getAccessToken());
		OutputTemateData outputData = new OutputTemateData();
		outputData.setTouser(openid);
		outputData.setTemplate_id(templateId);
		TemplateDate templateDate = new TemplateDate();
		Data_First first = new Data_First();
		first.setValue("您好，亲爱的" + sendee + "家长");
		first.setColor("#18b4ed");
		Data_Keyword keyword1 = new Data_Keyword();
		keyword1.setValue(schoolName);
		Data_Keyword keyword2 = new Data_Keyword();
		keyword2.setValue(sender + "老师");
		Data_Keyword keyword3 = new Data_Keyword();
		keyword3.setValue(DateUtil.dateToStr(new Date(), DateUtil.DEFAULT_DATE_FORMAT));
		Data_Keyword keyword4 = new Data_Keyword();
		keyword4.setValue(content);
		keyword4.setColor("#19c43e");
		Data_Remark remark = new Data_Remark();
		remark.setValue("\n\n❀❀❀欢迎使用"+school.getSchoolName()+"公众号❀❀❀");
		outputData.setUrl(reqUrl);
		templateDate.setFirst(first);
		templateDate.setKeyword1(keyword1);
		templateDate.setKeyword2(keyword2);
		templateDate.setKeyword3(keyword3);
		templateDate.setKeyword4(keyword4);
		templateDate.setRemark(remark);
		outputData.setData(templateDate);
		try {
			String json = JSONObject.toJSONString(outputData);
			json = json.replace("clazz", "class");
			HttpClientUtils.postStringJosn(url, json);
		} catch (Exception e) {
			logger.error("--classNoticeSend, error={}", e);
		}
	}
	
	/**
	 * 作业通知
	 * @param openid
	 * @param sendee 接收人
	 * @param schoolName 学校
	 * @param sender 发送人
	 * @param content 消息内容
	 * @param templateId 模板编号
	 */
	public static void homeworkNoticeSend(SchoolInfo school,String openid, String sendee, String sender, 
			String subject, String content, String templateId, String reqUrl) {
		String url = TextUtil.format(WechatConfigure.getInstance().getTemplateMsg(), 
				school.getAccessToken());
		OutputTemateData outputData = new OutputTemateData();
		outputData.setTouser(openid);
		outputData.setTemplate_id(templateId);
		TemplateDate templateDate = new TemplateDate();
		Data_First first = new Data_First();
		first.setValue("您好，亲爱的" + sendee + "家长，有新的作业已布置，请查收");
		first.setColor("#18b4ed");
		Data_Keyword keyword1 = new Data_Keyword();
		keyword1.setValue(DateUtil.dateToStr(new Date(), DateUtil.DEFAULT_DATE_FORMAT2));
		Data_Keyword keyword2 = new Data_Keyword();
		keyword2.setValue(subject);
		Data_Keyword keyword3 = new Data_Keyword();
		keyword3.setValue(sender + "老师布置的作业");
		Data_Keyword keyword4 = new Data_Keyword();
		keyword4.setValue(content);
		keyword4.setColor("#19c43e");
		Data_Remark remark = new Data_Remark();
		remark.setValue("\n\n❀❀❀欢迎使用"+school.getSchoolName()+"公众号❀❀❀");
		outputData.setUrl(reqUrl);
		templateDate.setFirst(first);
		templateDate.setKeyword1(keyword1);
		templateDate.setKeyword2(keyword2);
		templateDate.setKeyword3(keyword3);
		templateDate.setKeyword4(keyword4);
		templateDate.setRemark(remark);
		outputData.setData(templateDate);
		try {
			String json = JSONObject.toJSONString(outputData);
			json = json.replace("clazz", "class");
			HttpClientUtils.postStringJosn(url, json);
		} catch (Exception e) {
			logger.error("--classNoticeSend, error={}", e);
		}
	}
	
	/**
	 * 班级相册通知提醒
	 * @param openid
	 * @param sendee
	 * @param gradeClass
	 * @param teacherName
	 * @param content
	 * @param reqUrl
	 */
	public static void classAlbumNoticeSend(SchoolInfo school,String templateId, String openid, String sendee,
			String gradeClass, String teacherName, String content, String reqUrl) {
		String url = TextUtil.format(WechatConfigure.getInstance().getTemplateMsg(), 
				school.getAccessToken());
		OutputTemateData outputData = new OutputTemateData();
		outputData.setTouser(openid);
		outputData.setTemplate_id(templateId);
		TemplateDate templateDate = new TemplateDate();
		Data_First first = new Data_First();
		first.setValue("您好，亲爱的" + sendee + "家长，老师发布了新的班级相册，请查收");
		first.setColor("#18b4ed");
		Data_Keyword keyword1 = new Data_Keyword();
		keyword1.setValue(gradeClass);
		Data_Keyword keyword2 = new Data_Keyword();
		keyword2.setValue(teacherName + "老师");
		Data_Keyword keyword3 = new Data_Keyword();
		keyword3.setValue(DateUtil.dateToStr(new Date(), DateUtil.DEFAULT_DATE_FORMAT2));
		Data_Keyword keyword4 = new Data_Keyword();
		keyword4.setValue(content);
		keyword4.setColor("#19c43e");
		Data_Remark remark = new Data_Remark();
		remark.setValue("\n\n❀❀❀欢迎使用"+school.getSchoolName()+"公众号❀❀❀");
		outputData.setUrl(reqUrl);
		templateDate.setFirst(first);
		templateDate.setKeyword1(keyword1);
		templateDate.setKeyword2(keyword2);
		templateDate.setKeyword3(keyword3);
		templateDate.setKeyword4(keyword4);
		templateDate.setRemark(remark);
		outputData.setData(templateDate);
		try {
			String json = JSONObject.toJSONString(outputData);
			json = json.replace("clazz", "class");
			HttpClientUtils.postStringJosn(url, json);
		} catch (Exception e) {
			logger.error("--classNoticeSend, error={}", e);
		}
	}
	
	/**
	 * 请假审批结果通知
	 * @param openid
	 * @param sendee
	 * @param teacherName
	 * @param result
	 * @param reqUrl
	 */
	public static void studentLeaveAuditSend(SchoolInfo school,String templateId,String openid, String sendee,
			String teacherName, String result, String reqUrl) {
		String url = TextUtil.format(WechatConfigure.getInstance().getTemplateMsg(), 
				school.getAccessToken());
		OutputTemateData outputData = new OutputTemateData();
		outputData.setTouser(openid);
		outputData.setTemplate_id(templateId);
		TemplateDate templateDate = new TemplateDate();
		Data_First first = new Data_First();
		first.setValue("您好，亲爱的" + sendee + "家长，您的请假申请已审批，请查收");
		first.setColor("#18b4ed");
		Data_Keyword keyword1 = new Data_Keyword();
		keyword1.setValue(result);
		Data_Keyword keyword2 = new Data_Keyword();
		keyword2.setValue(teacherName + "老师");
		Data_Keyword keyword3 = new Data_Keyword();
		keyword3.setValue(DateUtil.dateToStr(new Date(), DateUtil.DEFAULT_DATE_FORMAT2));
		Data_Remark remark = new Data_Remark();
		remark.setValue("\n\n❀❀❀欢迎使用"+school.getSchoolName()+"公众号❀❀❀");
		outputData.setUrl(reqUrl);
		templateDate.setFirst(first);
		templateDate.setKeyword1(keyword1);
		templateDate.setKeyword2(keyword2);
		templateDate.setKeyword3(keyword3);
		templateDate.setRemark(remark);
		outputData.setData(templateDate);
		try {
			String json = JSONObject.toJSONString(outputData);
			json = json.replace("clazz", "class");
			HttpClientUtils.postStringJosn(url, json);
		} catch (Exception e) {
			logger.error("--classNoticeSend, error={}", e);
		}
	}
	
	public static void stuentLeaveApplySend(SchoolInfo school,String templateId,String openid, String sendee,
			String studentName, Date startTime, Date endTime, String leaveReason, 
			String reqUrl) {
		String url = TextUtil.format(WechatConfigure.getInstance().getTemplateMsg(), 
				school.getAccessToken());
		OutputTemateData outputData = new OutputTemateData();
		outputData.setTouser(openid);
		outputData.setTemplate_id(templateId);
		TemplateDate templateDate = new TemplateDate();
		Data_First first = new Data_First();
		first.setValue("您好，亲爱的" + sendee + "老师，您接收到了一个请假申请，请查收");
		first.setColor("#18b4ed");
		Data_ChildName childName = new Data_ChildName();
		childName.setValue(studentName);
		Data_Time time = new Data_Time();
		time.setValue(DateUtil.dateToStr(startTime, DateUtil.DEFAULT_DATE_FORMAT2)+"-" + DateUtil.dateToStr(endTime, DateUtil.DEFAULT_DATE_FORMAT2));
		Data_Score score = new Data_Score();
		score.setValue(leaveReason);
		score.setColor("#19c43e");
		Data_Remark remark = new Data_Remark();
		remark.setValue("\n\n家长正等着您的反馈，请点击详情进行确认。\n\n❀❀❀欢迎使用"+school.getSchoolName()+"公众号❀❀❀");
		outputData.setUrl(reqUrl);
		templateDate.setFirst(first);
		templateDate.setChildName(childName);
		templateDate.setTime(time);
		templateDate.setScore(score);
		templateDate.setRemark(remark);
		outputData.setData(templateDate);
		try {
			String json = JSONObject.toJSONString(outputData);
			json = json.replace("clazz", "class");
			HttpClientUtils.postStringJosn(url, json);
		} catch (Exception e) {
			logger.error("--classNoticeSend, error={}", e);
		}
	}
	
	public static void teacherLeaveApplySend(SchoolInfo school,String templateId,String openid, String sendee,
			String teacherName, Date startTime, Date endTime, String leaveReason, 
			String leaveType, String reqUrl) {
		String url = TextUtil.format(WechatConfigure.getInstance().getTemplateMsg(), 
				school.getAccessToken());
		OutputTemateData outputData = new OutputTemateData();
		outputData.setTouser(openid);
		outputData.setTemplate_id(templateId);
		TemplateDate templateDate = new TemplateDate();
		Data_First first = new Data_First();
		first.setValue("您好，亲爱的" + sendee + "老师，您接收到了一个请假申请，请查收");
		first.setColor("#18b4ed");
		Data_Keyword keyword1 = new Data_Keyword();
		keyword1.setValue(teacherName);
		Data_Keyword keyword2 = new Data_Keyword();
		keyword2.setValue(leaveType);
		Data_Keyword keyword3 = new Data_Keyword();
		keyword3.setValue(DateUtil.dateToStr(startTime, DateUtil.DEFAULT_DATE_FORMAT2)+"-" + DateUtil.dateToStr(endTime, DateUtil.DEFAULT_DATE_FORMAT2));
		Data_Keyword keyword4 = new Data_Keyword();
		keyword4.setValue(leaveReason);
		keyword4.setColor("#19c43e");
		Data_Remark remark = new Data_Remark();
		remark.setValue("\n\n老师正等着您的反馈，请点击详情进行确认。\n\n❀❀❀欢迎使用"+school.getSchoolName()+"公众号❀❀❀");
		outputData.setUrl(reqUrl);
		templateDate.setFirst(first);
		templateDate.setKeyword1(keyword1);
		templateDate.setKeyword2(keyword2);
		templateDate.setKeyword3(keyword3);
		templateDate.setKeyword4(keyword4);
		templateDate.setRemark(remark);
		outputData.setData(templateDate);
		try {
			String json = JSONObject.toJSONString(outputData);
			json = json.replace("clazz", "class");
			HttpClientUtils.postStringJosn(url, json);
		} catch (Exception e) {
			logger.error("--classNoticeSend, error={}", e);
		}
	}
	
	/**
	 * 请假审批通知
	 * @param openid
	 * @param auditResult
	 * @param auditer
	 * @param auditedDate
	 * @param reqUrl
	 */
	public static void leaveAuditSend(SchoolInfo school,String templateId,String openid, String auditTips, String auditResult,
			String auditer, Date auditedDate, String reqUrl) {
		String url = TextUtil.format(WechatConfigure.getInstance().getTemplateMsg(), 
				school.getAccessToken());
		OutputTemateData outputData = new OutputTemateData();
		outputData.setTouser(openid);
		outputData.setTemplate_id(templateId);
		TemplateDate templateDate = new TemplateDate();
		Data_First first = new Data_First();
		first.setValue(auditTips);
		first.setColor("#18b4ed");
		Data_Keyword keyword1 = new Data_Keyword();
		keyword1.setValue(auditResult);
		keyword1.setColor("#19c43e");
		Data_Keyword keyword2 = new Data_Keyword();
		keyword2.setValue(auditer);
		Data_Keyword keyword3 = new Data_Keyword();
		keyword3.setValue(DateUtil.dateToStr(auditedDate, DateUtil.DEFAULT_DATE_FORMAT2));
		Data_Remark remark = new Data_Remark();
		remark.setValue("\n\n❀❀❀欢迎使用"+school.getSchoolName()+"公众号❀❀❀");
		outputData.setUrl(reqUrl);
		templateDate.setFirst(first);
		templateDate.setKeyword1(keyword1);
		templateDate.setKeyword2(keyword2);
		templateDate.setKeyword3(keyword3);
		templateDate.setRemark(remark);
		outputData.setData(templateDate);
		try {
			String json = JSONObject.toJSONString(outputData);
			json = json.replace("clazz", "class");
			HttpClientUtils.postStringJosn(url, json);
		} catch (Exception e) {
			logger.error("--classNoticeSend, error={}", e);
		}
	}
	
	/**
	 * 学生课程辅导通知
	 * @param openid
	 * @param teacherName
	 * @param studentName
	 * @param gradeClass
	 * @param startTime
	 * @param endTime
	 * @param leaveReason
	 * @param reqUrl
	 */
	public static void studentCoachSend(SchoolInfo school,String templateId,String openid, String teacherName, String studentName, String gradeClass,
			Date startTime, Date endTime, String leaveReason, String reqUrl) {
		String url = TextUtil.format(WechatConfigure.getInstance().getTemplateMsg(), 
				school.getAccessToken());
		OutputTemateData outputData = new OutputTemateData();
		outputData.setTouser(openid);
		outputData.setTemplate_id(templateId);
		TemplateDate templateDate = new TemplateDate();
		Data_First first = new Data_First();
		first.setValue("您好，亲爱的" + teacherName + "老师，您接收到了一个课程辅导提醒，请查收");
		first.setColor("#18b4ed");
		Data_Keyword keyword1 = new Data_Keyword();
		keyword1.setValue(studentName);
		Data_Keyword keyword2 = new Data_Keyword();
		keyword2.setValue(gradeClass);
		Data_Keyword keyword3 = new Data_Keyword();
		keyword3.setValue(DateUtil.dateToStr(startTime, DateUtil.DEFAULT_DATE_FORMAT2)+"-" + DateUtil.dateToStr(endTime, DateUtil.DEFAULT_DATE_FORMAT2));
		Data_Remark remark = new Data_Remark();
		remark.setValue("\n请假原因：" + leaveReason + "\n\n学生到校后，请您及时进行课程辅导\n\n❀❀❀欢迎使用"+school.getSchoolName()+"公众号❀❀❀");
		outputData.setUrl(reqUrl);
		templateDate.setFirst(first);
		templateDate.setKeyword1(keyword1);
		templateDate.setKeyword2(keyword2);
		templateDate.setKeyword3(keyword3);
		templateDate.setRemark(remark);
		outputData.setData(templateDate);
		try {
			String json = JSONObject.toJSONString(outputData);
			json = json.replace("clazz", "class");
			HttpClientUtils.postStringJosn(url, json);
		} catch (Exception e) {
			logger.error("--classNoticeSend, error={}", e);
		}
	}
	
	/**
	 * 工作审批通知
	 * @param openid
	 * @param sendee
	 * @param content
	 * @param workDate
	 * @param templateId
	 * @param reqUrl
	 */
	public static void coordinationOfficeSend(SchoolInfo school,String openid, String sendee, String content, 
			String workDate, String templateId, String reqUrl) {
		String url = TextUtil.format(WechatConfigure.getInstance().getTemplateMsg(), 
				school.getAccessToken());
		OutputTemateData outputData = new OutputTemateData();
		outputData.setTouser(openid);
		outputData.setTemplate_id(templateId);
		TemplateDate templateDate = new TemplateDate();
		Data_First first = new Data_First();
		first.setValue("您好，亲爱的" + sendee + "老师，您有一条新的工作提醒");
		first.setColor("#18b4ed");
		Data_Keyword keyword1 = new Data_Keyword();
		keyword1.setValue(workDate + "工作安排");
		Data_Keyword keyword2 = new Data_Keyword();
		keyword2.setValue(workDate);
		Data_Keyword keyword3 = new Data_Keyword();
		keyword3.setValue(content);
		keyword3.setColor("#19c43e");
		Data_Remark remark = new Data_Remark();
		remark.setValue("\n\n❀❀❀欢迎使用"+school.getSchoolName()+"公众号❀❀❀");
		outputData.setUrl(reqUrl);
		templateDate.setFirst(first);
		templateDate.setKeyword1(keyword1);
		templateDate.setKeyword2(keyword2);
		templateDate.setKeyword3(keyword3);
		templateDate.setRemark(remark);
		outputData.setData(templateDate);
		try {
			String json = JSONObject.toJSONString(outputData);
			json = json.replace("clazz", "class");
			HttpClientUtils.postStringJosn(url, json);
		} catch (Exception e) {
			logger.error("--coordinationOfficeSend, error={}", e);
		}
	}
	
	/**
	 * 学生上校车通知
	 * @param openid
	 * @param studentName
	 * @param boardTime
	 * @param lineName
	 * @param templateId
	 * @param reqUrl
	 */
	public static void schoolbusStudentBoardSend(SchoolInfo school,String openid, String studentName, 
			Date boardTime, String lineName, String templateId, String reqUrl) {
		String url = TextUtil.format(WechatConfigure.getInstance().getTemplateMsg(),school.getAccessToken());
		OutputTemateData outputData = new OutputTemateData();
		outputData.setTouser(openid);
		outputData.setTemplate_id(templateId);
		TemplateDate templateDate = new TemplateDate();
		Data_First first = new Data_First();
		first.setValue("您好！您的小孩已上校车,点击“详情”可以实时查看小孩位置");
		first.setColor("#18b4ed");
		Data_Keyword keyword1 = new Data_Keyword();
		keyword1.setValue(studentName);
		Data_Keyword keyword2 = new Data_Keyword();
		keyword2.setValue(DateUtil.dateToStr(boardTime, DateUtil.DEFAULT_DATE_FORMAT2));
		Data_Keyword keyword3 = new Data_Keyword();
		keyword3.setValue("上车提醒");
		keyword3.setColor("#19c43e");
		Data_Keyword keyword4 = new Data_Keyword();
		keyword4.setValue(lineName);
		Data_Remark remark = new Data_Remark();
		remark.setValue("\n\n❀❀❀欢迎使用"+school.getSchoolName()+"公众号❀❀❀");
		templateDate.setFirst(first);
		templateDate.setKeyword1(keyword1);
		templateDate.setKeyword2(keyword2);
		templateDate.setKeyword3(keyword3);
		templateDate.setKeyword4(keyword4);
		templateDate.setRemark(remark);
		outputData.setUrl(reqUrl);
		outputData.setData(templateDate);
		try {
			String json = JSONObject.toJSONString(outputData);
			json = json.replace("clazz", "class");
			HttpClientUtils.postStringJosn(url, json);
		} catch (Exception e) {
			logger.error("--schoolbusStudentBoardSend, error={}", e);
		}
	}
	
	public static void schoolbusStudentSend(SchoolInfo school,String openid, String studentName, 
			String boardTime, String lineName, String typeName, String reqUrl) {
		String url = TextUtil.format(WechatConfigure.getInstance().getTemplateMsg(), school.getAccessToken());
		OutputTemateData outputData = new OutputTemateData();
		outputData.setTouser(openid);
		outputData.setTemplate_id("vNRhmhepzymHwDzPMKMPXdoTiAuCTnI8wh64wa3C4kw");
		TemplateDate templateDate = new TemplateDate();
		Data_First first = new Data_First();
		first.setValue("家长您好！小孩校车考勤状态已更新,可以点击“详情”查看");
		first.setColor("#18b4ed");
		Data_Keyword keyword1 = new Data_Keyword();
		keyword1.setValue(studentName);
		Data_Keyword keyword2 = new Data_Keyword();
		keyword2.setValue(boardTime);
		Data_Keyword keyword3 = new Data_Keyword();
		keyword3.setValue(typeName);
		keyword3.setColor("#19c43e");
		Data_Keyword keyword4 = new Data_Keyword();
		keyword4.setValue(lineName);
		Data_Remark remark = new Data_Remark();
		remark.setValue("\n\n❀❀❀欢迎使用"+school.getSchoolName()+"公众号❀❀❀");
		templateDate.setFirst(first);
		templateDate.setKeyword1(keyword1);
		templateDate.setKeyword2(keyword2);
		templateDate.setKeyword3(keyword3);
		templateDate.setKeyword4(keyword4);
		templateDate.setRemark(remark);
		outputData.setUrl(reqUrl);
		outputData.setData(templateDate);
		try {
			String json = JSONObject.toJSONString(outputData);
			json = json.replace("clazz", "class");
			HttpClientUtils.postStringJosn(url, json);
		} catch (Exception e) {
			logger.error("--schoolbusStudentUnderSend, error={}", e);
		}
	}
	
	public static void doorStudentSend(SchoolInfo school,String templateId,String openid, String studentName, 
			String addTime, String studyNo, String typeName, String cardType) {
		String url = TextUtil.format(WechatConfigure.getInstance().getTemplateMsg(), school.getAccessToken());
		OutputTemateData outputData = new OutputTemateData();
		outputData.setTouser(openid);
		outputData.setTemplate_id(templateId);
		TemplateDate templateDate = new TemplateDate();
		Data_First first = new Data_First();
		first.setValue("家长您好！小孩在学校进行了门禁刷卡，结果请您知悉");
		first.setColor("#18b4ed");
		Data_Keyword keyword1 = new Data_Keyword();
		keyword1.setValue(studentName);
		Data_Keyword keyword2 = new Data_Keyword();
		keyword2.setValue(studyNo);
		Data_Keyword keyword3 = new Data_Keyword();
		keyword3.setValue(addTime);
		Data_Keyword keyword4 = new Data_Keyword();
		keyword4.setValue(typeName);
		keyword4.setColor("#19c43e");
		Data_Keyword keyword5 = new Data_Keyword();
		keyword5.setValue(cardType);
		Data_Remark remark = new Data_Remark();
		remark.setValue("\n\n❀❀❀欢迎使用"+school.getSchoolName()+"公众号❀❀❀");
		templateDate.setFirst(first);
		templateDate.setKeyword1(keyword1);
		templateDate.setKeyword2(keyword2);
		templateDate.setKeyword3(keyword3);
		templateDate.setKeyword4(keyword4);
		templateDate.setKeyword5(keyword5);
		templateDate.setRemark(remark);
		outputData.setData(templateDate);
		try {
			String json = JSONObject.toJSONString(outputData);
			json = json.replace("clazz", "class");
			HttpClientUtils.postStringJosn(url, json);
		} catch (Exception e) {
			logger.error("--schoolbusStudentUnderSend, error={}", e);
		}
	}
	
	/**
	 * 报修申请通知
	 * @param openid
	 * @param repairName 报修人
	 * @param repairTime 报修时间
	 * @param repairPlace 报修地点
	 * @param repairContent 报修内容
	 * @param templateId 模板id
	 */
	public static void repairApplySend(SchoolInfo school,String openid, String repairName, 
			Date repairTime, String repairPlace, String repairContent, 
			String templateId, String reqUrl) {
		String url = TextUtil.format(WechatConfigure.getInstance().getTemplateMsg(), 
				school.getAccessToken());
		OutputTemateData outputData = new OutputTemateData();
		outputData.setTouser(openid);
		outputData.setTemplate_id(templateId);
		TemplateDate templateDate = new TemplateDate();
		Data_First first = new Data_First();
		first.setValue("您好！有一个新的报修申请，请及时处理");
		first.setColor("#18b4ed");
		Data_Keyword keyword1 = new Data_Keyword();
		keyword1.setValue(repairName);
		Data_Keyword keyword2 = new Data_Keyword();
		keyword2.setValue(DateUtil.dateToStr(repairTime, DateUtil.DEFAULT_DATE_FORMAT2));
		Data_Keyword keyword3 = new Data_Keyword();
		keyword3.setValue(repairPlace);
		Data_Keyword keyword4 = new Data_Keyword();
		keyword4.setValue(repairContent);
		Data_Remark remark = new Data_Remark();
		remark.setValue("\n\n❀❀❀欢迎使用"+school.getSchoolName()+"公众号❀❀❀");
		templateDate.setFirst(first);
		templateDate.setKeyword1(keyword1);
		templateDate.setKeyword2(keyword2);
		templateDate.setKeyword3(keyword3);
		templateDate.setKeyword4(keyword4);
		templateDate.setRemark(remark);
		outputData.setData(templateDate);
		outputData.setUrl(reqUrl);
		try {
			String json = JSONObject.toJSONString(outputData);
			json = json.replace("clazz", "class");
			HttpClientUtils.postStringJosn(url, json);
		} catch (Exception e) {
			logger.error("--repairApplySend, error={}", e);
		}
	}
	
	public static void repairResultSend(SchoolInfo school,String openid, String repairName, 
			String repairContent, String repaireName, String repaireResult,
			String templateId, String reqUrl) {
		String url = TextUtil.format(WechatConfigure.getInstance().getTemplateMsg(), 
				school.getAccessToken());
		OutputTemateData outputData = new OutputTemateData();
		outputData.setTouser(openid);
		outputData.setTemplate_id(templateId);
		TemplateDate templateDate = new TemplateDate();
		Data_First first = new Data_First();
		first.setValue("您好，您的维修项目已经处理完毕");
		first.setColor("#18b4ed");
		Data_Keyword keyword1 = new Data_Keyword();
		keyword1.setValue(repairName);
		Data_Keyword keyword2 = new Data_Keyword();
		keyword2.setValue(repairContent);
		Data_Keyword keyword3 = new Data_Keyword();
		keyword3.setValue("维修组");
		Data_Keyword keyword4 = new Data_Keyword();
		keyword4.setValue(repaireName);
		Data_Keyword keyword5 = new Data_Keyword();
		keyword5.setValue(repaireResult);
		Data_Remark remark = new Data_Remark();
		remark.setValue("\n\n❀❀❀欢迎使用"+school.getSchoolName()+"公众号❀❀❀");
		templateDate.setFirst(first);
		templateDate.setKeyword1(keyword1);
		templateDate.setKeyword2(keyword2);
		templateDate.setKeyword3(keyword3);
		templateDate.setKeyword4(keyword4);
		templateDate.setKeyword5(keyword5);
		templateDate.setRemark(remark);
		outputData.setData(templateDate);
		outputData.setUrl(reqUrl);
		try {
			String json = JSONObject.toJSONString(outputData);
			json = json.replace("clazz", "class");
			HttpClientUtils.postStringJosn(url, json);
		} catch (Exception e) {
			logger.error("--repairResultSend, error={}", e);
		}
	}

	public static void approvalApplySend(SchoolInfo school,String openid, String approvalType,
			String applyName, String applyContent, Date applyTime,
			String templateId, String reqUrl) {
		String url = TextUtil.format(WechatConfigure.getInstance().getTemplateMsg(), 
				school.getAccessToken());
		OutputTemateData outputData = new OutputTemateData();
		outputData.setTouser(openid);
		outputData.setTemplate_id(templateId);
		TemplateDate templateDate = new TemplateDate();
		Data_First first = new Data_First();
		first.setValue("您好！有一个新的待处理的审批，请及时处理");
		first.setColor("#18b4ed");
		Data_Keyword keyword1 = new Data_Keyword();
		keyword1.setValue(approvalType);
		Data_Keyword keyword2 = new Data_Keyword();
		keyword2.setValue(applyName);
		Data_Keyword keyword3 = new Data_Keyword();
		keyword3.setValue(applyContent);
		Data_Keyword keyword4 = new Data_Keyword();
		keyword4.setValue(DateUtil.dateToStr(applyTime, DateUtil.DEFAULT_DATE_FORMAT2));
		Data_Remark remark = new Data_Remark();
		remark.setValue("\n\n❀❀❀欢迎使用"+school.getSchoolName()+"公众号❀❀❀");
		templateDate.setFirst(first);
		templateDate.setKeyword1(keyword1);
		templateDate.setKeyword2(keyword2);
		templateDate.setKeyword3(keyword3);
		templateDate.setKeyword4(keyword4);
		templateDate.setRemark(remark);
		outputData.setData(templateDate);
		outputData.setUrl(reqUrl);
		try {
			String json = JSONObject.toJSONString(outputData);
			json = json.replace("clazz", "class");
			HttpClientUtils.postStringJosn(url, json);
		} catch (Exception e) {
			logger.error("--repairApplySend, error={}", e);
		}
	}
	
	public static void approvalResultSend(SchoolInfo school,String openid, String title, String approvalType,
			String approvalResult, Date approvalTime, String templateId, 
			String reqUrl) {
		String url = TextUtil.format(WechatConfigure.getInstance().getTemplateMsg(), 
				school.getAccessToken());
		OutputTemateData outputData = new OutputTemateData();
		outputData.setTouser(openid);
		outputData.setTemplate_id(templateId);
		TemplateDate templateDate = new TemplateDate();
		Data_First first = new Data_First();
		first.setValue(title);
		first.setColor("#18b4ed");
		Data_Keyword keyword1 = new Data_Keyword();
		keyword1.setValue(approvalType);
		Data_Keyword keyword2 = new Data_Keyword();
		keyword2.setValue(approvalResult);
		Data_Keyword keyword3 = new Data_Keyword();
		keyword3.setValue(DateUtil.dateToStr(approvalTime, DateUtil.DEFAULT_DATE_FORMAT2));
		Data_Remark remark = new Data_Remark();
		remark.setValue("\n\n❀❀❀欢迎使用"+school.getSchoolName()+"公众号❀❀❀");
		templateDate.setFirst(first);
		templateDate.setKeyword1(keyword1);
		templateDate.setKeyword2(keyword2);
		templateDate.setKeyword3(keyword3);
		templateDate.setRemark(remark);
		outputData.setData(templateDate);
		outputData.setUrl(reqUrl);
		try {
			String json = JSONObject.toJSONString(outputData);
			json = json.replace("clazz", "class");
			HttpClientUtils.postStringJosn(url, json);
		} catch (Exception e) {
			logger.error("--repairApplySend, error={}", e);
		}
	}
	
	public static void courseChangeSend(SchoolInfo school,String openid, 
			String templateId, String studentName, String reqUrl) {
		String url = TextUtil.format(WechatConfigure.getInstance().getTemplateMsg(), 
				school.getAccessToken());
		OutputTemateData outputData = new OutputTemateData();
		outputData.setTouser(openid);
		outputData.setTemplate_id(templateId);
		TemplateDate templateDate = new TemplateDate();
		Data_First first = new Data_First();
		first.setValue("您好，" + studentName + "的家长，您的调班申请班主任已审批，请查收");
		first.setColor("#18b4ed");
		Data_Keyword keyword1 = new Data_Keyword();
		keyword1.setValue("调班申请");
		Data_Keyword keyword2 = new Data_Keyword();
		keyword2.setValue(DateUtil.dateToStr(new Date(), DateUtil.DEFAULT_DATE_FORMAT2));
		Data_Remark remark = new Data_Remark();
		remark.setValue("\n\n❀❀❀欢迎使用"+school.getSchoolName()+"公众号❀❀❀");
		outputData.setUrl(reqUrl);
		templateDate.setFirst(first);
		templateDate.setKeyword1(keyword1);
		templateDate.setKeyword2(keyword2);
		templateDate.setRemark(remark);
		outputData.setData(templateDate);
		try {
			String json = JSONObject.toJSONString(outputData);
			json = json.replace("clazz", "class");
			HttpClientUtils.postStringJosn(url, json);
		} catch (Exception e) {
			logger.error("--classNoticeSend, error={}", e);
		}
	}
	
	public static void courseMemberChangeSend(SchoolInfo school,String openid, 
			String templateId, String teacherName, 
			String addStudentName, String backStudentName, Integer memberCount, 
			String courseName, String reqUrl) {
		String url = TextUtil.format(WechatConfigure.getInstance().getTemplateMsg(), 
				school.getAccessToken());
		OutputTemateData outputData = new OutputTemateData();
		outputData.setTouser(openid);
		outputData.setTemplate_id(templateId);
		TemplateDate templateDate = new TemplateDate();
		Data_First first = new Data_First();
		first.setValue("您好，亲爱的" + teacherName + "老师，“"+courseName+"”课程，班级成员有变动，请知悉");
		first.setColor("#18b4ed");
		Data_Keyword keyword1 = new Data_Keyword();
		keyword1.setValue(addStudentName);
		Data_Keyword keyword2 = new Data_Keyword();
		keyword2.setValue(backStudentName);
		Data_Keyword keyword3 = new Data_Keyword();
		keyword3.setValue(memberCount + "人");
		Data_Remark remark = new Data_Remark();
		remark.setValue("\n\n❀❀❀欢迎使用"+school.getSchoolName()+"公众号❀❀❀");
		outputData.setUrl(reqUrl);
		templateDate.setFirst(first);
		templateDate.setKeyword1(keyword1);
		templateDate.setKeyword2(keyword2);
		templateDate.setKeyword3(keyword3);
		templateDate.setRemark(remark);
		outputData.setData(templateDate);
		try {
			String json = JSONObject.toJSONString(outputData);
			json = json.replace("clazz", "class");
			HttpClientUtils.postStringJosn(url, json);
		} catch (Exception e) {
			logger.error("--classNoticeSend, error={}", e);
		}
	}
	
	/**
	 * 评语提醒家长回评
	 * @param openid
	 * @param studentName
	 * @param commentContent
	 * @param status
	 * @param reqUrl
	 */
	public static void commentNoticeParentSend(SchoolInfo school,String templateId,String openid, String studentName, 
			String commentContent, Integer status, String reqUrl) {
		String url = TextUtil.format(WechatConfigure.getInstance().getTemplateMsg(), 
				school.getAccessToken());
		OutputTemateData outputData = new OutputTemateData();
		outputData.setTouser(openid);
		outputData.setTemplate_id(templateId);
		TemplateDate templateDate = new TemplateDate();
		Data_First first = new Data_First();
		String statusV = WeekCommentStatus.TEACHER.getCode() == status ? "回评" : "查看";
		first.setValue("亲爱的家长，" + studentName + "同学的本周班主任评语已出，请" + statusV);
		first.setColor("#18b4ed");
		Data_Keyword keyword1 = new Data_Keyword();
		keyword1.setValue(studentName);
		Data_Keyword keyword2 = new Data_Keyword();
		keyword2.setValue(commentContent);
		keyword2.setColor("#19c43e");
		Data_Keyword keyword3 = new Data_Keyword();
		keyword3.setValue(DateUtil.dateToStr(new Date(), DateUtil.DEFAULT_DATE_FORMAT2));
		Data_Remark remark = new Data_Remark();
		remark.setValue("\n\n点击”详情“"+statusV+"\n\n❀❀❀欢迎使用"+school.getSchoolName()+"公众号❀❀❀");
		outputData.setUrl(reqUrl);
		templateDate.setFirst(first);
		templateDate.setKeyword1(keyword1);
		templateDate.setKeyword2(keyword2);
		templateDate.setKeyword3(keyword3);
		templateDate.setRemark(remark);
		outputData.setData(templateDate);
		try {
			String json = JSONObject.toJSONString(outputData);
			json = json.replace("clazz", "class");
			logger.info("----commentNoticeParentSend, param={}", json);
			HttpClientUtils.postStringJosn(url, json);
		} catch (Exception e) {
			logger.error("--commentNoticeParentSend, error={}", e);
		}
	}
	
	/**
	 * 提醒教师评价通知
	 * @param openid
	 * @param schoolName
	 * @param teacherName
	 * @param studentCount
	 * @param reqUrl
	 */
	public static void comemntRemaindTeacherSend(SchoolInfo school,String templateId,String openid, String schoolName, 
			String teacherName, int studentCount, String reqUrl) {
		String url = TextUtil.format(WechatConfigure.getInstance().getTemplateMsg(), 
				school.getAccessToken());
		OutputTemateData outputData = new OutputTemateData();
		outputData.setTouser(openid);
		outputData.setTemplate_id(templateId);
		TemplateDate templateDate = new TemplateDate();
		Data_First first = new Data_First();
		first.setValue("亲爱的" + teacherName + "老师，本周还有" + studentCount + "位学生还未评，请知悉");
		first.setColor("#18b4ed");
		Data_Keyword keyword1 = new Data_Keyword();
		keyword1.setValue(schoolName);
		Data_Keyword keyword2 = new Data_Keyword();
		keyword2.setValue("系统通知");
		Data_Keyword keyword3 = new Data_Keyword();
		keyword3.setValue(DateUtil.dateToStr(new Date(), DateUtil.DEFAULT_DATE_FORMAT));
		Data_Keyword keyword4 = new Data_Keyword();
		keyword4.setValue("本周评语提醒");
		Data_Remark remark = new Data_Remark();
		remark.setValue("\n\n点击”详情“进行评价\n❀❀❀欢迎使用"+school.getSchoolName()+"公众号❀❀❀");
		outputData.setUrl(reqUrl);
		templateDate.setFirst(first);
		templateDate.setKeyword1(keyword1);
		templateDate.setKeyword2(keyword2);
		templateDate.setKeyword3(keyword3);
		templateDate.setKeyword4(keyword4);
		templateDate.setRemark(remark);
		outputData.setData(templateDate);
		try {
			String json = JSONObject.toJSONString(outputData);
			json = json.replace("clazz", "class");
			logger.info("----comemntRemaindTeacherSend, param={}", json);
			HttpClientUtils.postStringJosn(url, json);
		} catch (Exception e) {
			logger.error("--comemntRemaindTeacherSend, error={}", e);
		}
	}
	
	public static void replaceCourseSend(SchoolInfo school,String templateId,String openid, String teacherName, String applyTeacherName,
			String classGrade, String courseDate, String reqUrl) {
		String url = TextUtil.format(WechatConfigure.getInstance().getTemplateMsg(), 
				school.getAccessToken());
		OutputTemateData outputData = new OutputTemateData();
		outputData.setTouser(openid);
		outputData.setTemplate_id(templateId);
		TemplateDate templateDate = new TemplateDate();
		Data_First first = new Data_First();
		first.setValue("亲爱的" + teacherName + "老师，您收到一条来自"+applyTeacherName+"老师的代看课申请，请知悉");
		first.setColor("#18b4ed");
		Data_Keyword keyword1 = new Data_Keyword();
		keyword1.setValue(courseDate);
		Data_Keyword keyword2 = new Data_Keyword();
		keyword2.setValue(classGrade);
		Data_Remark remark = new Data_Remark();
		remark.setValue("\n\n点击”详情“查看详情\n❀❀❀欢迎使用"+school.getSchoolName()+"公众号❀❀❀");
		outputData.setUrl(reqUrl);
		templateDate.setFirst(first);
		templateDate.setKeyword1(keyword1);
		templateDate.setKeyword2(keyword2);
		templateDate.setRemark(remark);
		outputData.setData(templateDate);
		try {
			String json = JSONObject.toJSONString(outputData);
			json = json.replace("clazz", "class");
			logger.info("----replaceCourseSend, param={}", json);
			HttpClientUtils.postStringJosn(url, json);
		} catch (Exception e) {
			logger.error("--replaceCourseSend, error={}", e);
		}
	}
	
	public static void changeCourseSend(SchoolInfo school,String templateId,String openid, String teacherName, String applyTeacherName,
			String classSubject, String currDateLesson, String exchangeDateLesson, String reqUrl) {
		String url = TextUtil.format(WechatConfigure.getInstance().getTemplateMsg(), 
				school.getAccessToken());
		OutputTemateData outputData = new OutputTemateData();
		outputData.setTouser(openid);
		outputData.setTemplate_id(templateId);
		TemplateDate templateDate = new TemplateDate();
		Data_First first = new Data_First();
		first.setValue("亲爱的" + teacherName + "老师，您收到一条来自"+applyTeacherName+"老师的调代看课申请，请审批");
		first.setColor("#18b4ed");
		Data_Keyword keyword1 = new Data_Keyword();
		keyword1.setValue(classSubject);
		Data_Keyword keyword2 = new Data_Keyword();
		keyword2.setValue(currDateLesson);
		Data_Keyword keyword3 = new Data_Keyword();
		keyword3.setValue(exchangeDateLesson);
		Data_Remark remark = new Data_Remark();
		remark.setValue("\n\n点击”详情“查看详情\n❀❀❀欢迎使用"+school.getSchoolName()+"公众号❀❀❀");
		outputData.setUrl(reqUrl);
		templateDate.setFirst(first);
		templateDate.setKeyword1(keyword1);
		templateDate.setKeyword2(keyword2);
		templateDate.setKeyword3(keyword3);
		templateDate.setRemark(remark);
		outputData.setData(templateDate);
		try {
			String json = JSONObject.toJSONString(outputData);
			json = json.replace("clazz", "class");
			logger.info("----changeCourseSend, param={}", json);
			HttpClientUtils.postStringJosn(url, json);
		} catch (Exception e) {
			logger.error("--changeCourseSend, error={}", e);
		}
	}
	
	public static void auditChangeCourseSend(SchoolInfo school,String templateId,String openid, String teacherName, String applyTeacherName,
			String reason, String reqUrl) {
		String url = TextUtil.format(WechatConfigure.getInstance().getTemplateMsg(), 
				school.getAccessToken());
		OutputTemateData outputData = new OutputTemateData();
		outputData.setTouser(openid);
		outputData.setTemplate_id(templateId);
		TemplateDate templateDate = new TemplateDate();
		Data_First first = new Data_First();
		first.setValue("亲爱的" + teacherName + "老师，您收到一条来自"+applyTeacherName+"老师的调代看课申请，请审批");
		first.setColor("#18b4ed");
		Data_Keyword keyword1 = new Data_Keyword();
		keyword1.setValue("调代看课");
		Data_Keyword keyword2 = new Data_Keyword();
		keyword2.setValue(applyTeacherName);
		Data_Keyword keyword3 = new Data_Keyword();
		keyword3.setValue(reason);
		Data_Remark remark = new Data_Remark();
		remark.setValue("\n\n点击”详情“查看详情\n❀❀❀欢迎使用"+school.getSchoolName()+"公众号❀❀❀");
		outputData.setUrl(reqUrl);
		templateDate.setFirst(first);
		templateDate.setKeyword1(keyword1);
		templateDate.setKeyword2(keyword2);
		templateDate.setKeyword3(keyword3);
		templateDate.setRemark(remark);
		outputData.setData(templateDate);
		try {
			String json = JSONObject.toJSONString(outputData);
			json = json.replace("clazz", "class");
			logger.info("----auditChangeCourseSend, param={}", json);
			HttpClientUtils.postStringJosn(url, json);
		} catch (Exception e) {
			logger.error("--auditChangeCourseSend, error={}", e);
		}
	}
	
	public static void auditResultSend(SchoolInfo school,String templateId,String openid, String approver, String result,
			Date auditDate, String msg, String reqUrl) {
		String url = TextUtil.format(WechatConfigure.getInstance().getTemplateMsg(), 
				school.getAccessToken());
		OutputTemateData outputData = new OutputTemateData();
		outputData.setTouser(openid);
		outputData.setTemplate_id(templateId);
		TemplateDate templateDate = new TemplateDate();
		Data_First first = new Data_First();
		first.setValue(msg);
		first.setColor("#18b4ed");
		Data_Keyword keyword1 = new Data_Keyword();
		keyword1.setValue(approver);
		Data_Keyword keyword2 = new Data_Keyword();
		keyword2.setValue(result);
		Data_Keyword keyword3 = new Data_Keyword();
		keyword3.setValue(DateUtil.dateToStr(auditDate, DateUtil.DEFAULT_DATE_FORMAT2));
		Data_Remark remark = new Data_Remark();
		remark.setValue("\n\n点击”详情“查看详情\n❀❀❀欢迎使用"+school.getSchoolName()+"公众号❀❀❀");
		outputData.setUrl(reqUrl);
		templateDate.setFirst(first);
		templateDate.setKeyword1(keyword1);
		templateDate.setKeyword2(keyword2);
		templateDate.setKeyword3(keyword3);
		templateDate.setRemark(remark);
		outputData.setData(templateDate);
		try {
			String json = JSONObject.toJSONString(outputData);
			json = json.replace("clazz", "class");
			logger.info("----auditResultSend, param={}", json);
			HttpClientUtils.postStringJosn(url, json);
		} catch (Exception e) {
			logger.error("--auditResultSend, error={}", e);
		}
	}
}
